package com.emeraude;

import java.awt.Canvas;

public class Battle extends Canvas
{

  /**
   * 
   */
  private static final long serialVersionUID = -1610577966845824594L;
  /*
  private final JPanel      panel;
  //private final BufferStrategy strategy;
  private final JFrame      container;
  public final Container    oldContainer;
  private final Game        game;
  JLabel                    battleStart      = new JLabel("Battle Start");

  public Battle(final Game game)
  {
   this.game = game;
   oldContainer = game.getContainer().getContentPane();
   this.container = game.getContainer();
   panel = new JPanel();
   panel.setPreferredSize(new Dimension(WorldMap.TILD_WIDTH * WorldMap.NB_TILD_ON_SCREEN, WorldMap.TILD_HEIGHT * WorldMap.NB_TILD_ON_SCREEN));
   panel.setLayout(null);
   panel.setBackground(new Color(255, 255, 255));
   // setup our canvas size and put it into the content of the frame
   setBounds(0, 0, WorldMap.MAP_WIDTH, WorldMap.MAP_HEIGHT);

   panel.add(this);
   container.setContentPane(panel);
   // Tell AWT not to bother repainting our canvas since we're
   // going to do that our self in accelerated mode
   setIgnoreRepaint(true);

   // finally make the window visible 
   container.pack();
   container.setResizable(false);
   container.setVisible(true);

   // add a key input system (defined below) to our canvas
   // so we can respond to key pressed
   addKeyListener(new KeyInputHandler());

   // request the focus so key events come to us
   requestFocus();
   fight();
  }

  public void fight()
  {
   System.out.println("ok");
   panel.add(battleStart);
   final JLabel label = new JLabel("oookkk");
   panel.add(label);
   panel.setVisible(true);
   container.validate();
   container.repaint();
  }

  class KeyInputHandler extends KeyAdapter
  {

   @Override public void keyPressed(final KeyEvent e)
   {
     if (e.getKeyCode() == KeyEvent.VK_B)
     {
       //panel.setVisible(false);
       //System.out.println("exit");
     }
   }

   @Override public void keyReleased(final KeyEvent e)
   {
     if (e.getKeyCode() == KeyEvent.VK_B)
     {
       //panel.setVisible(false);
       //container.remove(panel);

       container.setContentPane(oldContainer);
       game.setBattleInProgess(false);
       game.requestFocus();
       //System.out.println("exit2");
     }
   }

   @Override public void keyTyped(final KeyEvent e)
   {

     // if we hit escape, then quit the game
     if (e.getKeyChar() == 27)
     {
       System.exit(0);
     }
     if (e.getKeyCode() == KeyEvent.VK_C)
     {
       // panel.setVisible(false);
       System.out.println("exit3");
     }
   }
  }*/
}
